<%@ page language="java" contentType="text/html; charset=utf-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>鼎嘉国际-旅游攻略管理</title>
</head>
<body>
<%@include file="menu.jsp" %>

 
 <div class="layui-body">
    <!-- 内容主体区域 -->
   <div style="padding: 15px;">
    <h3 class="title">旅游攻略管理</h3>
    <table class="layui-hide" id="test" lay-filter="test"></table>
    </div>
  </div>
  
  <div class="layui-footer">
    <!-- 底部固定区域 -->
    © layui.com - 底部固定区域
  </div>
</div>
<script src="${base}/statics/layui/layui.js"></script>
<script type="text/html" id="toolbarDemo">
  <div class="layui-btn-container">
    <button class="layui-btn layui-btn-sm" lay-event="getCheckData">获取选中行数据</button>
    <button class="layui-btn layui-btn-sm" lay-event="getCheckLength">获取选中数目</button>
    <button class="layui-btn layui-btn-sm" lay-event="isAll">验证是否全选</button>
  </div>
</script>
 
<script type="text/html" id="barDemo">
  <a class="layui-btn layui-btn-xs" lay-event="edit">编辑</a>
  <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a>
</script>
              
          
<!-- 注意：如果你直接复制所有代码到本地，上述js路径需要改成你本地的 --> 
 
<script>
layui.use('table', function(){
  var table = layui.table;
  
  table.render({
    elem: '#test'
    ,url:'${base}'+'/strategy/viewstrategy.do'
    ,toolbar: '#toolbarDemo'
    ,title: '旅游攻略表'
    ,cols: [[
      {type: 'checkbox', fixed: 'left'}
      ,{field:'id', title:'ID', width:80, fixed: 'left', unresize: true, sort: true}
      ,{field:'title', title:'标题',width:200}
      ,{field:'p1', title:'概要标题', width:120, edit: 'text'}
      ,{field:'page1', title:'概要信息', width:300, edit: 'text', templet: function(res){
        return '<em>'+ res.page1 +'</em>'
      }}
      ,{field:'praise', title:'点赞数量', width:150, edit: 'text',sort: true }
      ,{field:'readcount', title:'阅读数量', width:120,sort: true}
      
      ,{field:'time', title:'更新时间', width:120}
      ,{field:'author', title:'作者', width:120}
      ,{fixed: 'right', title:'操作', toolbar: '#barDemo', width:150}
    ]]
    ,page: true
    ,even: true 
  });
  
  //头工具栏事件
  table.on('toolbar(test)', function(obj){
    var checkStatus = table.checkStatus(obj.config.id);
    switch(obj.event){
      case 'getCheckData':
        var data = checkStatus.data;
        layer.alert(JSON.stringify(data));
      break;
      case 'getCheckLength':
        var data = checkStatus.data;
        layer.msg('选中了：'+ data.length + ' 个');
      break;
      case 'isAll':
        layer.msg(checkStatus.isAll ? '全选': '未全选');
      break;
    };
  });
  
  //监听行工具事件
  table.on('tool(test)', function(obj){
    var data = obj.data;
    //console.log(obj)
    if(obj.event === 'del'){
      layer.confirm('真的删除行么', function(index){
        obj.del();
        layer.close(index);
      });
    } else if(obj.event === 'edit'){
      layer.prompt({
        formType: 2
        ,value: data.page1
      }, function(value, index){
        obj.update({
        	page1: value
        });
        layer.close(index);
      });
    }
  });
});
</script>
</body>
</html>